//
//  RNOLAuthPayViewController.m
//  RongNiuOnline
//
//  Created by apple on 2018/4/25.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLAuthPayViewController.h"
#import "RNOLTableFormCell.h"
#import "RNOLAuthPayFooter.h"


@interface RNOLAuthPayViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *dataArray;

@end

@implementation RNOLAuthPayViewController

- (UITableView *)tableView{
    if(!_tableView){
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH , KHIGHT) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = KWhiteColor;
        adjustsScrollViewInsets_NO(_tableView, self);
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 50;
        UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH , 15)];
        header.backgroundColor = kBgColor;
        _tableView.tableHeaderView = header;
        
        UIView *footerBg = [RNOLUnitTool createViewWithBackgroundColor:KWhiteColor];
        footerBg.frame = CGRectMake(0, 0, KWIDTH , 200);
        RNOLAuthPayFooter *footer = [RNOLAuthPayFooter FromXIB];
        footer.frame = footerBg.bounds;
        [footerBg addSubview: footer];
        _tableView.tableFooterView = footerBg;
        [_tableView registerClass:[RNOLTableFormCell class] forCellReuseIdentifier:NSStringFromClass([RNOLTableFormCell class])];
        [self.view addSubview: _tableView];
    }
    return _tableView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kBgColor;
    [self setupNavBarTitleViewWithText:@"开通认证支付"];
    [self configData];
}

- (void)configData{
    self.dataArray = [RNOLAuthPayModel getModelDataSource];
    [self.tableView reloadData];
}


#pragma mark -  UITableViewDelegate && UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    RNOLTableFormCell *cell = [tableView dequeueReusableCellWithIdentifier: NSStringFromClass([RNOLTableFormCell class])];
    cell.model = self.dataArray[indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return UIView.alloc.init;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return UIView.alloc.init;
}

- (void)viewDidLayoutSubviews
{
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
    }
    
    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
    }
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    
}


@end
